<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>宝钢彩涂板管理后台</title>
    <link rel="stylesheet" href="/static/css/normalize.css">
    <link rel="stylesheet" href="/static/css/login.css">
    <script type="text/javascript" src="/static/js/jquery-1.11.1.min.js"></script>
</head>
<body>
	<!-- LOGO -->
	<div class="logo-box fadeInDown">
		<!-- <img src="" alt="" width="330px;"> -->
	</div>
	<!-- 登录内容 -->
	<div class="wrapper fadeInDown">
  		<div id="formContent">
    		<h2 class="inactive underlineHover">用户登录</h2>
    		<!-- 图标SVG -->
    		<div class="fadeIn first">
      			<img src="/static/images/icon.svg" id="icon" alt="User Icon" />
    		</div>
    		<!-- 登录表单 -->
    		<form action="{:Url('login/login')}" method="post" id="login_form">
      			<input type="text" id="username" class="fadeIn second" name="username" placeholder="账号">
      			<input type="password" id="password" class="fadeIn third" name="password" placeholder="密码">
      			<input type="text" id="verify" class="fadeIn code" name="" placeholder="请输入验证码" style="width: 55%;">
      			<img src="{:Url('verify')}" alt="验证码" onclick="this.src='{:Url('verify')}'" class="fadeIn img" width="150px" height="50px" style="margin: -6px 5px 0px 5px;">
      			<input type="button" class="fadeIn fourth" onclick="login_ajax()" value="登录一下">
    		</form>
  		</div>
	</div>
</body>
<script>
	function login_ajax(){
	    var username = $('#username').val();
	    var password = $('#password').val();
	    var verify = $('#verify').val();
	    var u = $('#login_form').attr('action');
	    if(username == ''){
	        alert('请输入正确的用户名');
	        return false;
		}
		if (password == ''){
	        alert('请输入正确的密码');
	        return false;
		}
		if (verify == ''){
		    alert('请输入验证码');
		    return false;
		}
	    //提交登陆信息
	    $.post(u,{username:username,password:password,verify:verify},function(data){
			if(data==666){
			    alert('登陆成功');
			    window.location.href="{:Url('index/index')}";
			}else if (data == 222){
			    alert('用户名与密码不匹配');
                $('.fadeIn').attr('src',"{:Url('verify')}"+Math.random());
			}else if (data == 444){
			    alert('验证码不正确');
                $('.fadeIn').attr('src',"{:Url('verify')}"+Math.random());
			}
		});
	}
</script>
</html>